package ro.dandanciu.webgallery.util.properties;

import java.util.Locale;

import org.springframework.context.support.ReloadableResourceBundleMessageSource;

public class PropertyReader {
	
	private ReloadableResourceBundleMessageSource res; 
	
	private static Locale locale;
	
	public PropertyReader(String file) {
		res = new ReloadableResourceBundleMessageSource() ; 
		res.setBasename(file);
		locale = Locale.getDefault();
	}
	
	public String getMessage(String key) {
		return res.getMessage(key, new Object[] {}, locale);
	}

	public String getMessage(String key, Object... args) {
		return res.getMessage(key, args, locale);
	}

	public Locale getLocale() {
		return locale;
	}

	public void setLocale(Locale locale) {
		PropertyReader.locale = locale;
	}

}
